package com.tuni.birthdaymoney.persistence.entity;

// Generated 28.04.2013 16:40:29 by Hibernate Tools 3.4.0.CR1

import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

import org.hibernate.annotations.Type;
import org.joda.time.DateTime;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;

/**
 * BmOperation generated by hbm2java
 */
@Entity
@Table(name = "BM_Operation")
public class Operation implements java.io.Serializable {

    private Integer id;
    private Person donator;
    private Person humanResources;
    private Person receiptor;
    private DateTime date;
    private int year;
    private BigDecimal amount;

    public Operation() {
    }

    public Operation(Person bmPersonByDonatorId, Person bmPersonByHumanResourcesId, Person bmPersonByReceptorId, DateTime date, int year,
            BigDecimal amount) {
        this.donator = bmPersonByDonatorId;
        this.humanResources = bmPersonByHumanResourcesId;
        this.receiptor = bmPersonByReceptorId;
        this.date = date;
        this.year = year;
        this.amount = amount;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "ID", unique = true, nullable = false)
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "DonatorID", nullable = false)
    public Person getDonator() {
        return this.donator;
    }

    public void setDonator(Person donator) {
        this.donator = donator;
    }

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "HumanResourcesID", nullable = false)
    public Person getHumanResources() {
        return this.humanResources;
    }

    public void setHumanResources(Person humanResources) {
        this.humanResources = humanResources;
    }

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "ReceiptorID", nullable = false)
    public Person getReceiptor() {
        return this.receiptor;
    }

    public void setReceiptor(Person receiptor) {
        this.receiptor = receiptor;
    }

    @Temporal(TemporalType.DATE)
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    @DateTimeFormat(iso = ISO.DATE)
    @Column(name = "Date_", nullable = false, length = 19)
    public DateTime getDate() {
        return this.date;
    }

    public void setDate(DateTime date) {
        this.date = date;
    }

    @Column(name = "Year_", nullable = false)
    public int getYear() {
        return this.year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    @Column(name = "Amount", nullable = false)
    @NotNull(message = "Amount can not be empty")
    public BigDecimal getAmount() {
        return this.amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

}
